package com.qingke.notlonely.command.system;

import java.util.ArrayList;
import java.util.List;

import com.qingke.notlonely.bean.User;
import com.qingke.notlonely.bean.UserPassword;
import com.qingke.notlonely.command.SystemCommand;
import com.qingke.notlonely.util.NLConsole;

public class DeleteUser extends SystemCommand{

	@Override
	public void execute() {
		int id=NLConsole.getInt("user id:");
		boolean isExist=dao.isUserExistById(id);
		if(!isExist){
			NLConsole.println("the user is not exist.");
			return ;
		}
		User user=dao.selectUserById(id);
		UserPassword userPassword=dao.selectUserPasswordById(id);
		
		List<Object> list=new ArrayList<>();
		list.add(userPassword);
		list.add(user);
		
		boolean isSuccess=dao.delete(list);
		if(isSuccess)
			NLConsole.println("delete user success.");
		else
			NLConsole.println("delete user failed.");
	}

}
